#include<linux/module.h>
#include<linux/init.h>
#include<linux/kallsyms.h>
MODULE_LICENSE("GPL");
static int __init __print_symbol_init(void);
static void __exit __print_symbol_exit(void);

// symbol a_symbol
int a_symbol(void)
{
	return 1;
}
EXPORT_SYMBOL(a_symbol);

int __init __print_symbol_init(void)
{
	char *fmt;
	unsigned long address;
	char *name;
	struct module * fmodule =NULL;
	address=(unsigned long) __builtin_return_address(0);
	fmt="it's the first part,\n %s";
	__print_symbol(fmt,address);
	printk("\n\n");
	name="psmouse";		//can use lsmod to show current module
	fmodule=find_module(name); //find the module of name=psmouse
	if(fmodule != NULL)
	{
		printk("fmodule->name; %s\n",fmodule->name);	

		//get start address of the module to address
		address=(unsigned long)fmodule->module_core;
		fmt="it's the second part,\n %s";
		__print_symbol(fmt,address);
	}
	printk("\n\n");

	address=(unsigned long)a_symbol;
	fmt="it's the third part,\n %s";
	__print_symbol(fmt,address);

	printk("\n\n");
	return 0;
}
void __exit __print_symbol_exit(void)
{
	printk("module exit ok!\n");
}
module_init(__print_symbol_init);
module_exit(__print_symbol_exit);
